home *** CD-ROM | disk | FTP | other *** search
Java Source | 2003-07-02 | 902 b | 40 lines |
- import java.sql.*;
-
- abstract class TabellaDB {
-
- Connection conn;
-
- public TabellaDB( Connection conn ) {
- this.conn = conn;
- }
-
- //Pattern Template Method
- public void generate() throws SQLException, Exception {
- try {
- drop();
- } catch( SQLException ex ) {
- //se la tabella non esiste prosegue...
- }
- create();
- fill();
- }
-
- abstract void drop() throws SQLException;
- abstract void create() throws SQLException;
- abstract void fill() throws SQLException, Exception;
-
- void execute( String sql ) throws SQLException {
- log( sql );
-
- Statement st = conn.createStatement();
- st.executeUpdate( sql );
- st.close();
- }
-
- void log( String message ) {
- System.out.println( message );
- }
-
-
- }
-